
// ------------------------------------------------------------------------ db --------------------------------------
import { authService, baseService, downServiceFile, getUrlDeleteId } from '../index'

/**
 * 登录系统
 * @param params {{id:""}}
 * @param options
 */
export function loginSystemApi(params:any, options:any = {}) {
    return authService('/login', 'post', params, {
        headers: {
            isToken: 'false'
        }
    })
}

/**
 * 获取验证码
 */
export function queryCodeImgApi(params:any, options:any = {}) {
    return authService('/captchaImage', 'get', params, {
        headers: {
            isToken: 'false'
        }
    })
}

/**
 * 查询用户详细信息
 * @param params
 * @param options
 */
export function queryUserInfoApi(params:any = {}, options:any = {}) {
    return authService('/admin/getInfo', 'get', params, { popError: false })
}


/**
 * 查询用户权限集合
 * @param params
 * @param options
 */
export function queryUserPermissionApi(params:any = {}, options:any = {}) {
    return authService('/admin/getRouters', 'get', params)
}

/**
 * 更新密码
 * @param params
 * @param options
 */
export function updateUserPasswordApi(params:any = {}, options:any = {}) {
    return authService('/profile/updatePwd', 'put', params, { params })
}

/**
 * 重置用户密码
 * @param params
 * @param options
 */
export function resetUserPasswordApi(params:any = {}, options:any = {}) {
    return authService('/admin/resetPwd', 'put', {}, { data: params })
}

/**
 * 查询用户列表
 * @param params
 * @param options
 */
export function queryUserListApi(params:any = {}, options:any = {}) {
    return authService('/admin/list', 'get', params, options)
}

/**
 * 删除用户
 * @param params
 * @param options
 */
export function deleteUserApi(params:any = {}, options:any = {}) {
    return authService('/admin/' + getUrlDeleteId(params), 'delete', {}, options)
}


/**
 * 用户详情
 * @param params
 * @param options
 */
export function queryUserDetailApi(params:any = {}, options:any = {}) {
    return authService('/admin/' + params.id, 'get', params, options)
}

/**
 * 查询机构下角色列表
 * @param params
 * @param options
 */
export function queryDeptRoleListApi(params:any = {}, options:any = {}) {
    return authService('/role/optionselect', 'get', params, options)
}

/**
 * 创建用户
 * @param params
 * @param options
 */
export function createUserApi(params:any = {}, options:any = {}) {
    return authService('/admin', 'post', params, options)
}

/**
 * 修改用户信息
 * @param params
 * @param options
 */
export function updateUserApi(params:any = {}, options:any = {}) {
    return authService('/admin', 'put', params, options)
}
/**
 * 复制用户
 * @param params
 * @param options
 */
export function copyUserApi(params:any = {}, options:any = {}) {
    return authService('/admin/copyUser', 'post', params, options)
}

/**
 * 导出用户
 * @param params
 * @param options
 */
export function changeUserStatusApi(params:any = {}, options:any = {}) {
    return authService('/admin/changeStatus', 'put', params, options)
}


/**
 * 查询用户个人信息
 * @param params
 * @param options
 */
export function queryUserProfileApi(params:any = {}, options:any = {}) {
    return authService('/profile', 'get', params, options)
}


/**
 * 修改用户个人信息
 * @param params
 * @param options
 */
export function updateUserProfileApi(params:any = {}, options:any = {}) {
    return authService('/profile', 'put', params, options)
}

/**
 * 用户头像上传
 * @param params
 * @param options
 */
export function uploadUserAvatarApi(params:any = {}, options:any = {}) {
    const send = new FormData()
    send.append('avatarFile', params.file)
    return authService('/profile/avatar', 'post', send, options)
}

/**
 * 下载用户导入模板
 * @param options
 */
export function downUserImportTemplateApi(options:any = {}) {
    return downServiceFile('/omc/system/user/importTemplate', '用户信息导入模版', {}, options)
}

/**
 * 导入用户
 * @param params {{file:File}}
 * @param options
 */
export function importUserApi(params:any = {}, options:any = {}) {
    const sendParams = { ...params }
    delete sendParams.file
    return downServiceFile('/system/user/importData', 'post', { file: params.file }, { params: sendParams })
}

/**
 * 导出用户信息
 * @param params
 * @param options
 */
export function exportUserApi(params:any = {}, options:any = {}) {
    return downServiceFile('/admin/export', '用户信息.xls', params, options, 'post')
}

